import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:flutter_jd/pages/tabbar/my/controller.dart';
import 'package:flutter_jd/routes/routing_constants.dart';
import 'package:flutter_jd/ui/widgets/kit.dart';
import 'package:get/get_state_manager/get_state_manager.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/route_manager.dart';

// 订单区域
class MyOrderWrap extends GetWidget<MyController> {
  @override
  Widget build(BuildContext context) {
    return Container(
      height: 80.h,
      margin: EdgeInsets.only(left: 10.w, right: 10.w, top: 12.h),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(10.r),
      ),
      child: Row(
        children: List.generate(
          controller.orderList.length,
          (index) => Expanded(
            child: Container(
              child: GestureDetector(
                onTap: () {
                  int orderIndex = controller.orderList[index]['orderIndex'];
                  if (orderIndex != -1) {
                    Get.toNamed(OrderRoute, arguments: {
                      'initTabIndex': orderIndex,
                    });
                  }
                },
                child: Container(
                  color: Colors.transparent,
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.center,
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      Kit.iconFont(
                        controller.orderList[index]['icon'],
                        Color(0xFF333333),
                        25.sp,
                      ),
                      Container(
                        margin: EdgeInsets.only(top: 8.h),
                        child: Text(
                          controller.orderList[index]['name'],
                          style: TextStyle(fontSize: 10.sp),
                        ),
                      ),
                    ],
                  ),
                ),
              ),
            ),
          ),
        ),
      ),
    );
  }
}
